package com.tj.shopping.service.impl;

import com.tj.shopping.entity.Goods;
import com.tj.shopping.entity.Goodsdetail;
import com.tj.shopping.mapper.GoodInfoMapper;
import com.tj.shopping.mapper.GoodsdetailMapper;
import com.tj.shopping.service.IGoodsdetailService;
import com.tj.shopping.util.MybatisUtil;
import org.apache.ibatis.session.SqlSession;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class GoodSdetailServiceImpl implements IGoodsdetailService {
    private GoodsdetailMapper mapper;

    @Override
        public int add(Goodsdetail goodsdetail) {
            SqlSession session = MybatisUtil.getSession(true);
            mapper = session.getMapper(GoodsdetailMapper.class);
            return mapper.add(goodsdetail);
        }

    @Override
    public Map<String, Object> searchGoodsDetail(Map<String,Object> map) {
        SqlSession session= MybatisUtil.getSession();
        mapper=session.getMapper(GoodsdetailMapper.class);
        List<Goodsdetail>list=mapper.searchGoodsDetail(map);
        Map<String,Object> m=new HashMap<>();
        if (null==list||list.isEmpty()){
            m.put("code",600);
            m.put("msg","暂未数据");
        }else{
            m.put("code",200);
            m.put("msg","成功");
            m.put("data",list);
        }
        MybatisUtil.close(session);
        return m;
    }

}
